package org.apache.ibatis.demo;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;

/**
 * 配置文件加载Demo
 *
 * @author zhaohui
 */
public class BuildSqlSessionFactoryDemo {

    public static void main(String[] args) throws Exception {
        // 定义资源文件
        InputStream resource = Resources.getResourceAsStream("org\\apache\\ibatis\\demo\\conf\\mybatis.xml");
        // 根据配置配置文件构建会话工厂
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(resource);
        System.out.println(sqlSessionFactory);
    }

}
